<template>
	<view>
		<!-- 模拟的标题 -->
		<!-- <image class="header" src="https://www.mescroll.com/img/beibei/header.jpg" mode="aspectFit"/> -->
		<nav-bar >新信息</nav-bar>
		<mescroll-body-diy ref="mescrollRef" @init="mescrollInit" top="0" bottom="100" @down="downCallback" @up="upCallback" >
			<!-- 轮播图 -->
			<!-- <Xsuu-swiper :swiperItems="swiperItems"></Xsuu-swiper> -->
			<!-- 分页的数据列表 -->
			<recruitment-list :list="goods"></recruitment-list>
			
		</mescroll-body-diy>
		
		<!-- 模拟的底部 -->
	<!-- 	<image class="footer" src="https://www.mescroll.com/img/beibei/footer.jpg" mode="aspectFit"/> -->
	</view>
</template>

<script>
	let _this
	import MescrollBodyDiy from "@/uni_modules/mescroll-uni/components/mescroll-diy/beibei/mescroll-body.vue";
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import XsuuSwiper from "../../../components/Xss-swiper/Xsuu-swiper.vue"
    import RecruitmentList from "@/components/Recruitment-list/Recruitment-list.vue"
	import navBar from "@/components/zhouWei-navBar/index";
	
	export default {
		mixins: [MescrollMixin], // 使用mixin
		components: {
			MescrollBodyDiy, // 避免与main.js注册的全局组件名称相同,否则注册组件失效(iOS真机 APP HBuilderX2.7.9)
			XsuuSwiper,
			navBar,
			RecruitmentList
		},
		data() {
			return {
				goods: [] ,// 数据列表
			}
		},
		mounted() {
			_this= this;
			//this.isLogin();
		},
		methods: {
			
			// 
			/*下拉刷新的回调 */
			downCallback() {
				// 这里加载你想下拉刷新的数据, 比如刷新轮播数据
				// loadSwiper();
				// 下拉刷新的回调,默认重置上拉加载列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
				this.mescroll.resetUpScroll()
			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				try {
				    const value = uni.getStorageSync('setUserData');
				    if (value) {
				        console.log(value);
				    }
					let pageNum = page.num; // 页码, 默认从1开始
					let pageSize = page.size; // 页长, 默认每页10条
					console.log("当前查看招聘信息页数为："+pageNum,"当前查看招聘信息页长为："+pageSize)
					const pageData={
						pageNum:pageNum,
						pageSize:pageSize
					}
					console.log(pageData)
				 //联网加载数据
				     //通过企业用户ID 获取到企业信息ID ，再通过企业信息ID获取到招聘信息列表
				   console.log("查询ID:"+value.user_id)
				    _this.$api.enterprise.getRecruitmentlist(pageData,value.user_id).then(res=>{
					console.log("进入查看招聘信息列表接口")
					console.log(res)
					let code=res.data.code
					let recuritListData=res.data.data
					let recuritListLen = recuritListData.length; 
					let totalPage = 0
					// 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
					let totalSize = 0
					// 接口返回的是否有下一页 (true/false)
					let hasNext = false
					
					//设置列表数据
					if(page.num == 1) this.goods = []; //如果是第一页需手动置空列表
					this.goods = this.goods.concat(recuritListData); //追加新数据
					setTimeout(()=>{
							this.mescroll.endSuccess(recuritListLen)
					},20)
				}).catch(err=>{
					console.log("接口调用失败")
					//联网失败, 结束加载
				 	this.mescroll.endErr();
				})
				} catch (e) {
				    // error
				}

			}
		}
	}
</script>

<style>
	image{width: 100%;vertical-align: bottom;height:auto;display: block;}
	.header{z-index: 9900;position: fixed;top: --window-top;left: 0;height: 180upx;background: white;}
	.footer{z-index: 9900;position: fixed;bottom: 0;left: 0;height: 100upx;background: white;}
	.search_box {
		margin-right: 30upx;
		width: 300upx;
		height: 64upx;
		background-color: #f5f5f5;
		border-radius: 32upx;
		display: flex;
		align-items: center;
		padding: 0upx 40upx;
	
		.prompt {
			font-size: 28upx;
			color: #cccccc;
		}
		.icon_search {
			background-image: url('../../../static/map_ic_search.png');
			background-position: center center;
			background-repeat: no-repeat;
			background-size: cover;
			width: 29upx;
			height: 28upx;
			margin-right: 20upx;
		}
	}
</style>
